'''limit = 2000000

s = [2]
x = 3

while s[-1] < limit:
	p = 1
	for n in s:
		if x % n == 0:
			p = 0
			break
	if p == True:
		s.append(x)
	x = x + 2

print(sum(s[:-1]))'''

def getprimes(limit):
	primes = []
	nums = range(2,limit+1)
	marked = [0] * limit
	p = 2
	for p in nums:
		if not marked[p-2]:
			n = 2
			a = p*n
			while(a <= limit):
				marked[a-2] = 1
				n = n + 1
				a = p*n
	for x in range(limit-1):
		if not marked[x]:
			primes.append(nums[x])
	return primes

print(sum(getprimes(2000000)))